﻿<%@ Page Language="C#" MasterPageFile="~/Shared/EOS.Master" AutoEventWireup="True"
    Inherits="ETRANPORT.Web.Forms.LichTrinh.DuyetLichTrinh" CodeBehind="DuyetLichTrinh.aspx.cs" %>

<%@ Import Namespace="ETRANPORT.Web.Common"%>
<%@ Import Namespace="EBAYVN.Util" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Assembly="ETRANPORT.Controls" Namespace="ETRANPORT.Controls" TagPrefix="ETRANPORT" %>

<asp:Content ID="head" ContentPlaceHolderID="headCPH" runat="server"> 
<script type="text/javascript">
        $(document).ready(function() {
            $(document).ready(function() {
            $("#divPhuongTien").dialog({
                    autoOpen: false,
                    modal: true,
                    minHeight: 100,
                    height: 'auto',
                    width: 'auto',
                    resizable: false,
                    open: function(event, ui) {
                    $(this).parent().appendTo("#divPhuongTienDlgContainer");
                    }
                });
            });
        });
        
    </script>
</asp:Content>
<asp:Content ID="content" ContentPlaceHolderID="ContentPlaceHolderMain" runat="server">
    <div id="divPhuongTienDlgContainer">
        <div id="divPhuongTien" style="display: none">
            <asp:UpdatePanel ID="upnlPhuongTien" runat="server" UpdateMode="Conditional">
				<ContentTemplate>
				    <table cellpadding="3" cellspacing="1" style="width: 800px;">
                        <tr>
                            <td class="crmcontainer">
                                <table class="crmtable">
                                    <tbody>
                                        <tr>
                                            <td class="crmcell right">
                                                Từ khóa
                                            </td>
                                            <td class="crmcell">
                                                <div class="left">
                                                    <ETRANPORT:TextBox PostBackControlId="btnFilterPT" ID="txtKeywordPT" runat="server" Width="250px" MaxLength="200" />
                                                </div>
                                                <div class="left">
                                                    <asp:Button ID="btnFiterPT" OnClick="btnFiterPT_Click" UseSubmitBehavior="false"
                                                        runat="server" CssClass="filter" Text="" />
                                                </div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
						<tr>
							<td class="ptop-10">
							    <div class="crmcontainer">
							        <ETRANPORT:Grid ID="gvPhuongTien" runat="server" UseCustomPager="true" OnRowCommand="gvPhuongTien_RowCommand" >
                                        <PagerSettings FirstPageText="phương tiện" PageButtonCount="2" />
                                        <Columns>
                                            <asp:TemplateField HeaderStyle-Width="10%" HeaderText="Mã ĐP">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lnkBtnID" runat="server" 
                                                        CommandArgument='<%# Eval("MAPT") %>' CommandName="SelectedPT"                                                         
                                                        Text='<%# HttpUtility.HtmlEncode(Eval("MAPT").ToString()) %>'></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="TENPT" HeaderText="Tên" HeaderStyle-Width="15%" />
                                            <asp:BoundField DataField="MOTA" HeaderText="Mô tả" HeaderStyle-Width="20%" />
                                             <asp:BoundField DataField="TAITRONGMAX" HeaderText="Tải trọng tối đa" HeaderStyle-Width="20%" />
                                             <asp:BoundField DataField="NAMSX" HeaderText="Năm sản xuất" HeaderStyle-Width="20%" />
                                            <asp:TemplateField HeaderText="Loại phương tiện" HeaderStyle-Width="20%">
                                                <ItemTemplate>
                                                    <%# Eval("LOAIPT")!=null? (Eval("LOAIPT.TENLPT")):"Chưa cập nhật" %>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                    </ETRANPORT:Grid>
                                </div>
							</td>
						</tr>
					</table>
				</ContentTemplate>
	        </asp:UpdatePanel>
        </div>
    </div>
    <asp:UpdatePanel ID="upnlInfor" UpdateMode="Conditional" runat="server">
        <ContentTemplate>
            
            <div class="crmcontainer">
                <div class="header" style="padding-left:300px; padding-top:10px;border-bottom:1px solid black;">
                    <asp:Label runat="server" ForeColor="Red" ID="lbHienTrang" CssClass="label" Text="" />
                </div>
                <table class="crmtable">
                        <tbody>
                            <tr>    
                                <td class="crmcell right width-125">Tài xế</td>
                                <td class="crmcell width-250">    
                                    <div class="left">
                                       <asp:Label runat="server" ID="lbTaiXe" CssClass="label" />
                                    </div>                                 
                                </td>
                                <td class="crmcell right width-125">Phụ xe 1</td>
                                <td class="crmcell"> 
                                    <asp:Label runat="server" ID="lbPX1" CssClass="label" />
                                </td>
                                <td class="crmcell right width-100"></td>
                                <td class="crmcell"></td>
                            </tr>
                            <tr>    
                                <td class="crmcell right width-125">Phụ xe 2</td>
                                <td class="crmcell width-250">    
                                    <div class="left">
                                       <asp:Label runat="server" ID="lbPX2" CssClass="label" />
                                    </div>                                 
                                </td>
                                <td class="crmcell right width-125">Phụ xe 3</td>
                                <td class="crmcell"> 
                                    <div class="left">
                                        <asp:Label runat="server" ID="lbPX3" CssClass="label" />
                                    </div>
                                </td>
                                <td class="crmcell right width-100"></td>
                                <td class="crmcell"></td>
                            </tr>
                            <tr>    
                                <td class="crmcell right width-125">Phụ xe 4</td>
                                <td class="crmcell width-250">    
                                    <div class="left">
                                       <asp:Label runat="server" ID="lbPX4"  CssClass="label"/>
                                    </div>                                 
                                </td>
                                <td class="crmcell right width-125">Phụ xe 5</td>
                                <td class="crmcell"> 
                                    <div class="left">
                                        <asp:Label runat="server" ID="lbPX5" CssClass="label" />
                                    </div>
                                </td>
                                <td class="crmcell right width-100"></td>
                                <td class="crmcell"></td>
                            </tr>
                        </tbody>
                    </table>
                <table class="crmtable">
                    <tbody>
                        <tr>    
                            <td class="crmcell right width-125">Mã lịch trình</td>
                            <td class="crmcell width-250">    
                                <div class="left">
                                    <asp:TextBox ID="txtMaLichTrinh" runat="server" Width="85px" MaxLength="10" TabIndex="1" />                            
                                </div>                                 
                            </td>
                            <td class="crmcell right width-125">Tên lịch trình</td>
                            <td class="crmcell"> 
                                <div class="left">
                                    <asp:TextBox ID="txtTenLichTrinh" runat="server" Width="400px" TabIndex="2" />
                                </div>
                                
                            </td>
                            <td class="crmcell right width-100"></td>
                            <td class="crmcell"></td>
                        </tr>
                        <tr>    
                            <td class="crmcell right width-125">Số toa hàng</td>
                            <td class="crmcell width-250">    
                                <div class="left">
                                    <asp:TextBox ID="txtSoToa" runat="server" Width="85px" MaxLength="10" TabIndex="1" />                            
                                </div>                                 
                            </td>
                            <td class="crmcell right width-125">Số NV phụ xe</td>
                            <td class="crmcell"> 
                                <div class="left">
                                    <asp:TextBox ID="txtSoNhanVienPhu" runat="server" Width="100px" TabIndex="2" />
                                </div>
                                
                            </td>
                            <td class="crmcell right width-100"></td>
                            <td class="crmcell"></td>
                        </tr>
                        <tr>    
                            <td class="crmcell right width-125">Địa điểm bắt đầu</td>
                            <td class="crmcell">    
                                <div class="left">
                                    <asp:DropDownList ID="ddlDiemBD" Width="100px" runat="server" />
                                </div>                                 
                            </td>
                            <td class="crmcell right width-125">Địa điểm kết thúc</td>
                            <td class="crmcell"> 
                                <div class="left">
                                    <asp:DropDownList ID="ddlDiemKT" Width="100px" runat="server" />
                                </div>
                                <div class="left filtered"></div>
                            </td>
                            <td class="crmcell right width-100"></td>
                            <td class="crmcell"></td>
                        </tr>
                        <tr>    
                            <td class="crmcell right width-125">Ngày bắt đầu</td>
                            <td class="crmcell width-250">    
                                <div class="left">
                                    <asp:TextBox ID="txtNgayBatDau"  tag="datevn" runat="server" Width="100px" TabIndex="5" />                            
                                </div>                                 
                            </td>
                            <td class="crmcell right width-125">Ngày kết thúc</td>
                            <td class="crmcell"> 
                                <div class="left">
                                    <asp:TextBox ID="txtNgayKetThuc" tag="datevn" runat="server" Width="100px" TabIndex="6" />
                                </div>
                                <div class="left filtered"></div>
                            </td>
                            <td class="crmcell right width-100"></td>
                            <td class="crmcell"></td>
                        </tr>
                        <tr>    
                            <td class="crmcell right width-125"></td>
                            <td class="crmcell width-250">    
                                <div class="left">
                                    
                                </div>       
                                <div class="left">
                                    
                                </div>
                                <div class="left width-225">
                                    
                                </div>
                                <div class="left">
                                    
                                </div>                          
                            </td>
                            
                        </tr>
                        <tr>    
                            <td class="crmcell right width-125">Phương tiện</td>
                            <td class="crmcell width-250">    
                                <div class="left">
                                    <asp:TextBox ID="txtMaPT" runat="server" Width="100px" TabIndex="7" />                            
                                </div>             
                                <div class="left">
                                    <asp:Button CssClass="pickup" runat="server" ID="btnBrowPhuongTien" 
                                        TabIndex="7" onclick="btnBrowPhuongTien_Click" OnClientClick="openDialogAndBlock('Chọn từ danh sách phương tiện', 700, 'divPhuongTien')" />
                                </div>                    
                            </td>
                            <td class="crmcell right width-125"></td>
                            <td class="crmcell"> 
                                <div class="left">
                                    
                                        <asp:Label runat="server" ID="lbTenPhuongTien" CssClass="label" />
                                </div>
                                
                            </td>
                            <td class="crmcell right width-100"></td>
                            <td class="crmcell"></td>
                        </tr>
                        <tr>    
                            <td class="crmcell right btop"></td>
                            <td class="crmcell btop" colspan="5">
                                <div class="left">
                                    <ETRANPORT:Button ID="btnFilter" runat="server" CssClass="filter"
                                        OnClick="btnFilter_Click" TabIndex="15" UseSubmitBehavior="false" />
                                </div>
                                <div class="left" style="display:none">
                                    <ETRANPORT:Button ID="btnSave" runat="server" CssClass="save"
                                        OnClick="btnSave_Click" TabIndex="16" UseSubmitBehavior="false" />
                                </div>
                                <div class="left">
                                    <ETRANPORT:Button ID="btnCancel" runat="server" CssClass="cancel" OnClick="btnCancel_Click" TabIndex="17" UseSubmitBehavior="false" />
                                </div>
                                <div class="left">
                                    <ETRANPORT:Button ID="btnDuyetDon" runat="server" CssClass="approve" OnClick="btnDelete_Click" TabIndex="18" />
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>  
    <br />
    <asp:UpdatePanel ID="upnlGrid" UpdateMode="Conditional" runat="server">
        <ContentTemplate>
            <div class="crmcontainer">
                <ETRANPORT:Grid ID="gvList" runat="server" UseCustomPager="true" OnRowCommand="gvList_RowCommand" PageSize="20">
                    <PagerSettings FirstPageText="lịch trình" PageButtonCount="2" />
                    <Columns>
                        <asp:TemplateField HeaderStyle-CssClass="checkbox">
                            <HeaderTemplate>
                                <input id="chkAllTop" title="Chọn hết / Bỏ chọn hết" name="chkAllTop" type="checkbox"
                                    onclick="CheckAllItems(this);" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <input id="Id" runat="server" type="hidden" value='<%# Eval("ID") %>' />
                                <input name="listIds" type="checkbox" value='<%# Eval("ID") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>            
                        <asp:TemplateField HeaderStyle-Width="90px" HeaderText="Mã đơn&nbsp;">
                            <ItemTemplate>
                                <asp:LinkButton ID="lnkBtnID" runat="server" CommandArgument='<%# Eval("ID") %>'
                                    CommandName="EditItem" Text='<%# Eval("ID") %>'></asp:LinkButton>
                            </ItemTemplate>
                            <ItemStyle Font-Bold="true" />
                        </asp:TemplateField>
                        <asp:BoundField HeaderStyle-Width="24%" HeaderText="Tên lịch trình" DataField="TENLICHVC" />
                        <asp:BoundField HeaderStyle-Width="10%" HeaderText="Số lượng toa" DataField="SOTOA" />
                        <asp:BoundField HeaderStyle-Width="10%" HeaderText="Số NV ĐK" DataField="SONVDANGKY" />
                       <asp:TemplateField HeaderStyle-Width="10%" HeaderText="Điểm bắt đầu">
                            <ItemTemplate>
                                <%# (Eval("DIADIEM") != null) ?Eval("DIADIEM.TENDIADIEM"):" Chưa cập nhật"
                                         %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="10%" HeaderText="Điểm kết thúc">
                            <ItemTemplate>
                                <%# (Eval("DIADIEM1") != null) ?Eval("DIADIEM1.TENDIADIEM"):" Chưa cập nhật"
                                         %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="10%" HeaderText="Tình trạng">
                            <ItemTemplate>
                                <%# (Eval("ISEMPTY") != null) ?
                                    bool.Parse(Eval("ISEMPTY").ToString()).Equals(true)?"Còn trống":"Đã nhận khách hàng":"Đã nhận khách hàng" %>
                            </ItemTemplate>
                            <ItemStyle Font-Bold="true" ForeColor="Red" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="10%" HeaderText="Ngày nhập">
                            <ItemTemplate>
                                <%# (Eval("NGAYNHAP") != null) ?
                                        String.Format("{0:dd/MM/yyyy}", Eval("NGAYNHAP"))
                                        : "" %>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
               </ETRANPORT:Grid>
               <br />
               <div class="crmcontainer">
               <div class="header"><strong>
                    DANH SÁCH LỊCH TRÌNH ĐÃ DUYỆT</strong>
                    <ETRANPORT:Button runat="server" ID="btnHuyDuyet" CssClass="button-other" Text="Hủy duyệt" OnClick="btnHuyDuyet_Click" />
               </div></div>
               <ETRANPORT:Grid ID="gvDaDuyet" runat="server" UseCustomPager="true" OnRowCommand="gvList_RowCommand" PageSize="20">
                    <PagerSettings FirstPageText="lịch trình" PageButtonCount="2" />
                    <Columns>
                        <asp:TemplateField HeaderStyle-CssClass="checkbox">
                            <HeaderTemplate>
                                <input id="chkAllTop" title="Chọn hết / Bỏ chọn hết" name="chkAllTop" type="checkbox"
                                    onclick="CheckAllItems(this);" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <input id="Iddd" runat="server" type="hidden" value='<%# Eval("ID") %>' />
                                <input name="listddIds" type="checkbox" value='<%# Eval("ID") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>            
                        <asp:TemplateField HeaderStyle-Width="90px" HeaderText="Mã đơn&nbsp;">
                            <ItemTemplate>
                                <asp:LinkButton ID="lnkBtnID" runat="server" CommandArgument='<%# Eval("ID") %>'
                                    CommandName="EditItem" Text='<%# Eval("ID") %>'></asp:LinkButton>
                            </ItemTemplate>
                            <ItemStyle Font-Bold="true" />
                        </asp:TemplateField>
                        <asp:BoundField HeaderStyle-Width="24%" HeaderText="Tên lịch trình" DataField="TENLICHVC" />
                        <asp:BoundField HeaderStyle-Width="10%" HeaderText="Số lượng toa" DataField="SOTOA" />
                        <asp:BoundField HeaderStyle-Width="10%" HeaderText="Số NV ĐK" DataField="SONVDANGKY" />
                       <asp:TemplateField HeaderStyle-Width="10%" HeaderText="Điểm bắt đầu">
                            <ItemTemplate>
                                <%# (Eval("DIADIEM") != null) ?Eval("DIADIEM.TENDIADIEM"):" Chưa cập nhật"
                                         %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="10%" HeaderText="Điểm kết thúc">
                            <ItemTemplate>
                                <%# (Eval("DIADIEM1") != null) ?Eval("DIADIEM1.TENDIADIEM"):" Chưa cập nhật"
                                         %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="10%" HeaderText="Tình trạng">
                            <ItemTemplate>
                                <%# (Eval("TTLICHTRINH") != null) ? 
                                        (Eval("TTLICHTRINH").ToString().Equals(TTLICHTRINH.LT_A.ToString()) ?"Còn trống":
                                                Eval("TTLICHTRINH").ToString().Equals(TTLICHTRINH.LT_B.ToString())?
                                                "Đã duyệt lịch trình":"Hoàn thành"): "Đã nhận khách hàng" %>
                            </ItemTemplate>
                            <ItemStyle Font-Bold="true" ForeColor="Red" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="10%" HeaderText="Ngày nhập">
                            <ItemTemplate>
                                <%# (Eval("NGAYNHAP") != null) ?
                                        String.Format("{0:dd/MM/yyyy}", Eval("NGAYNHAP"))
                                        : "" %>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
               </ETRANPORT:Grid>
           </div>
        </ContentTemplate>
    </asp:UpdatePanel> 
</asp:Content>
